package com.ruoyi.common.core.core.domain.model;

import java.security.Principal;

public class UserPrincipal extends LoginUser implements Principal {
    @Override
    public String getName() {
        if(getUserType()==null){
            throw new IllegalArgumentException("用户类型不能为空");
        }
        if(getUserId()==null){
            throw new IllegalArgumentException("用户ID不能为空");
        }
        return getUserType() + "_" + getUserId();
    }

    /**
     * 根据userid转换成Stomp的name
     */
    public static String stompConvertName(String loginType,Long userId){
        if(loginType==null){
            throw new IllegalArgumentException("loginType不能为空");
        }
        if(userId==null){
            throw new IllegalArgumentException("userId不能为空");
        }else{
            return loginType + "_" + userId;
        }
    }

}
